/**
 * 167. 两数之和 II - 输入有序数组
 * 给定一个有序数组 numbers，从中找出两个数满足相加之和等于目标数 target
 * @link https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted
 *
 * @param {number[]} numbers
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (numbers, target) {
    let start = 0;
    let end = numbers.length - 1;
    while (start < end) {
        const sum = numbers[start] + numbers[end];
        if (sum === target) return [start + 1, end + 1];
        if (sum < target) start++;
        else end--;
    }

    return null;
};
